// 章表

const { STRING, INTEGER } = require("sequelize");

const sequelize = require("../sequelize");

const chapter = sequelize.define("chapter", {
    title: {
        type: STRING(50),
        allowNull: false,
        unique: true,
        comment: "章名称"
    },
    createdate: {
        type: STRING,
        comment: "创建时间"
    },
    updated: {
        type: STRING,
        comment: "修改时间"
    },
    creator: {
        type: STRING,
        comment: "修改者"
    },
    updator: {
        type: STRING,
        comment: "修改者"
    },
    catalogueId:{
        type:INTEGER,

    }

}, { timestamps: false, underscored: true })

const catalogue = require("./catalogue")
chapter.associate = () => {
    chapter.belongsTo(catalogue, {
        foreignKey: "catalogueId",
        targetKey: "id"
    })
}

module.exports = chapter